/**
 * All rights Reserved, Designed By 林溪
 * Copyright:    Copyright(C) 2016-2020
 */

package com.module.boots.coder;

import java.sql.SQLException;

import com.module.boots.coder.application.ApplicationCoder;
import com.module.boots.coder.base.BaseCoder;
import com.module.boots.coder.business.BusinessCoder;
import com.module.boots.coder.utils.MysqlBeanUtils;
import com.module.boots.coder.view.ViewCoder;

/**
 * 代码生成工厂
 * @author：林溪
 * @date：2020年9月5日
 */
public class CoderFactory {

    /**
     * 初始化MYSQL连接工厂
     * @author 林溪
     * @param ip 数据库IP
     * @param port 数据库端口
     * @param dbName 数据库名称
     * @param userName 数据库用户名
     * @param password 数据库密码
     * @param projectName 项目名称
     * @param tableName 表名称
     * @param tableDescription 表描述
     * @param author 作者
     * @return CoderFactory
     */
    public static void initMysqlFactory(String ip, String port, String dbName, String userName, String password, String projectName, String tableName, String tableDescription, String author) {
        MysqlBeanUtils.setMysqlInfo(ip, port, dbName, userName, password);
        BaseCoder.setBaseInfo(projectName, tableName, tableDescription, author);
    }

    /**
     * 生成前端接口
     * @author 林溪  void
     */
    public static void createApplication() throws Exception {
        final ApplicationCoder app = new ApplicationCoder();
        app.createApplication();
    }

    /**
     * 生成前端接口入参
     * @author 林溪
     * @param paoName 入参类名称
     * @param paoDescription 入参类描述
     * @throws Exception void
     */
    public static void createPAO(String paoName, String paoDescription) throws Exception {
        final ApplicationCoder app = new ApplicationCoder();
        app.createPAO(paoName, paoDescription);
    }

    /**
     * 生成前端接口出参
     * @author 林溪
     * @param aoName 出参类名称
     * @param aoDescription 出参类描述
     * @throws Exception void
     */
    public static void createAO(String aoName, String aoDescription) throws Exception {
        final ApplicationCoder app = new ApplicationCoder();
        app.createAO(aoName, aoDescription);
    }

    /**
     * 生成后端接口
     * @author 林溪
     * @throws Exception void
     */
    public static void createView() throws Exception {
        final ViewCoder viewCoder = new ViewCoder();
        viewCoder.createView();
    }

    /**
     * 生成后端接口出参
     * @author 林溪
     * @param voName 出参类名称
     * @param voDescription 出参类描述
     * @throws Exception void
     */
    public static void createVO(String voName, String voDescription) throws Exception {
        final ViewCoder viewCoder = new ViewCoder();
        viewCoder.createVO(voName, voDescription);
    }

    /**
     * 生成后端接口入参
     * @author 林溪
     * @param pvoName 入参类名称
     * @param pvoDescription 入参类描述
     * @throws Exception void
     */
    public static void createPVO(String pvoName, String pvoDescription) throws Exception {
        final ViewCoder viewCoder = new ViewCoder();
        viewCoder.createPVO(pvoName, pvoDescription);
    }

    /**
     * 生成service类
     * @author 溪云阁
     * @throws SQLException void
     */
    public static void createService() throws Exception {
        final BusinessCoder businessCoder = new BusinessCoder();
        businessCoder.createService();
    }

    /**
     * 生成serviceimpl类
     * @author 溪云阁
     * @throws SQLException void
     */
    public static void createServiceimpl() throws Exception {
        final BusinessCoder businessCoder = new BusinessCoder();
        businessCoder.createServiceimpl();
    }

    /**
     * 生成dao类
     * @author 溪云阁
     * @throws SQLException void
     */
    public static void createDao() throws Exception {
        final BusinessCoder businessCoder = new BusinessCoder();
        businessCoder.createDao();
    }

    /**
     * 生成实体类
     * @author 溪云阁
     * @throws SQLException void
     */
    public static void createEntity() throws Exception {
        final BusinessCoder businessCoder = new BusinessCoder();
        businessCoder.createEntity();
    }

    /**
     * 生成XML文件
     * @author 溪云阁
     * @throws SQLException void
     */
    public static void createXML() throws Exception {
        final BusinessCoder businessCoder = new BusinessCoder();
        businessCoder.createXML();
    }

}
